package com.ym.common.utils.page;


import com.ym.common.utils.ServletUtil;

/**
 * 表格数据处理
 *
 * @author ruoyi
 */
public class TableSupport {
	public static final String PAGE_NUM = "pageNum";

	public static final String PAGE_SIZE = "pageSize";

	public static final String ORDER_BY_COLUMN = "orderByColumn";

	public static final String IS_ASC = "isAsc";

	/**
	 * 封装分页对象
	 */
	public static PageDomain getPageDomain() {
		PageDomain pageDomain = new PageDomain();
		Integer pageNum = ServletUtil.getParameterToInt(PAGE_NUM);
		if (pageNum != null) {
			pageDomain.setPageNum(pageNum);
		}
		Integer pageSize = ServletUtil.getParameterToInt(PAGE_SIZE);
		if (pageSize != null) {
			pageDomain.setPageSize(pageSize);
		}
		pageDomain.setOrderByColumn(ServletUtil.getParameter(ORDER_BY_COLUMN));
		pageDomain.setIsAsc(ServletUtil.getParameter(IS_ASC));
		return pageDomain;
	}

	public static PageDomain buildPageRequest() {
		return getPageDomain();
	}
}
